package com.example.sunsg.okhttptest.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import java.util.List;

import butterknife.ButterKnife;

/**
 * Created by sunsg on 16/12/15.
 */
public class SimpleRecyclerViewAdapter extends RecyclerView.Adapter {

    private Context mContext;
    private LayoutInflater mLayoutInflater;

    private List<SimpleRecyclerViewAdapterItem> mItem;

    public SimpleRecyclerViewAdapter(Context context) {
        mContext = context;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    public void setItems(List<SimpleRecyclerViewAdapterItem> items) {
        mItem = items;
        notifyDataSetChanged();
    }

    public SimpleRecyclerViewAdapterItem getItem(int position) {
        try {
            return mItem.get(position);
        } catch (Exception e) {

        }
        return null;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//        View view = mLayoutInflater.inflate(R.layout.item_tts_new_response, parent, false);
//        RecyclerView.ViewHolder holder = new TtsHabitViewHolder(view);
        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        TtsHabitViewHolder ttsHabitViewHolder = (TtsHabitViewHolder) holder;

    }

    @Override
    public int getItemCount() {
        return 5;//mItem == null ? 0 : mItem.size();
    }

    public static class TtsHabitViewHolder extends RecyclerView.ViewHolder {
//        @BindView(R.id.tv_title)
//        TextView tvTitle;
//        @BindView(R.id.flow_layout)
//        FlowLayout flowLayout;
        public TtsHabitViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }


    public static class SimpleRecyclerViewAdapterItem<T> {
        private T t;
        private int type;

        public SimpleRecyclerViewAdapterItem(T t, int type) {
            this.t = t;
            this.type = type;
        }

        public T getT() {
            return t;
        }

        public void setT(T t) {
            this.t = t;
        }

        public int getType() {
            return type;
        }

        public void setType(int type) {
            this.type = type;
        }
    }
}
